<?php echo form_open_multipart('item/add'); ?>
<div class="panelOptions">
	<div class="header1">Options</div>
	<div id="options">
		<ul>
			<li><input type="checkbox" name="addCategory" checked /> create new
				category if not exist</li>
			<li><input type="checkbox" name="addManufacturer" checked /> create
				new manufacturer if not exist</li>
			<li><input type="checkbox" name="updateItem" /> update item if same barcode</li>
		</ul>
	</div>
</div>
<div class="panelBatchMode">
	<div class="header1">Batch mode</div>
	<div class="batchMode">
		<div class="errorMessage2"><?php echo $file_error;?></div>
		<input type="file" name="userfile" /> <br /> You may like to upload a
		file instead of enter one by one. <a
			href="<?php echo asset_url();?>others/Inventory_100.txt">Click here</a>
		to see the example of the file
	</div>
</div>
<div class="panelClassic">
	<div class="header1">Classic</div>
	<div class="classic">
		<div class="classicTable">
			<table id="classicTable">
				<tr>
					<td>name</td>
					<td>barcode</td>
					<td>type</td>
					<td>category</td>
					<td>manufacturer</td>
					<td width="80px">cost</td>
					<td width="80px">selling price</td>
					<td width="80px">current stock</td>
					<td width="80px">mininum stock</td>
					<td width="80px">bundle unit</td>
				</tr>
				<tr>
					<td><input class="textboxStyle2" type="text" maxlength="30"
						name="name_0" />
					</td>
					<td><input class="textboxStyle5" type="number" maxlength="8" min ="0" max="99999999"
						name="barcode_0" />
					</td>
					<td><select class="selectStyle2" name="type_0" id="type_0">
					</select>
					</td>
					<td><input class="textboxStyle4" type="text" maxlength="30"
						name="category_0" />
					</td>
					<td><input class="textboxStyle4" type="text" maxlength="30"
						name="manufacturer_0" />
					</td>
					<td><input class="textboxStyle3" type="number" maxlength="30" min="0"
						name="cost_0" />
					</td>
					<td><input class="textboxStyle3" type="number" maxlength="30" min="0"
						name="price_0" />
					</td>
					<td><input class="textboxStyle3" type="number" maxlength="30" min="0"
						name="curr_stock_0" />
					</td>
					<td><input class="textboxStyle3" type="number" maxlength="30" min="0"
						name="min_stock_0" />
					</td>
					<td>
						<div id="tabParent_0">
							<input class="textboxStyle3" type="number" maxlength="30" min="0"
								name="bundle_unit_0" id="bundle_unit_0" />
						</div>
					</td>
				</tr>

				<tr>
					<td><input class="textboxStyle2" type="text" maxlength="30"
						name="name_1" />
					</td>
					<td><input class="textboxStyle5" type="number" maxlength="8" min ="0" max="99999999"
						name="barcode_1" />
					</td>
					<td><select class="selectStyle2" name="type_1" id="type_1">						
					</select>
					</td>
					<td><input class="textboxStyle4" type="text" maxlength="30"
						name="category_1" />
					</td>
					<td><input class="textboxStyle4" type="text" maxlength="30"
						name="manufacturer_1" />
					</td>
					<td><input class="textboxStyle3" type="number" maxlength="30" min="0"
						name="cost_1" />
					</td>
					<td><input class="textboxStyle3" type="number" maxlength="30" min="0"
						name="price_1" />
					</td>
					<td><input class="textboxStyle3" type="number" maxlength="30" min="0"
						name="curr_stock_1" />
					</td>
					<td><input class="textboxStyle3" type="number" maxlength="30" min="0"
						name="min_stock_1" />
					</td>
					<td>
						<div id="tabParent_1">
							<input class="textboxStyle3" type="number" maxlength="30" min="0"
								name="bundle_unit_1" id="bundle_unit_1" />
						</div>
					</td>
				</tr>
			</table>
		</div>
	</div>
	<script>
	$(function() {
		<?php 
		$data = array();
		foreach ($item_type as $row)
		{
			$data[$row->item_type_id] = $row->item_type_name;
		}
		?>
		
		var myOptions = <?php echo json_encode($data)?>;

		$.each(myOptions, function(val, text) {
			$('#type_0').append($('<option></option>').val(val).html(text));
			$('#type_1').append($('<option></option>').val(val).html(text));
		});


		
		var count = 1;

		function addRow(e) { 
			var keyCode = e.keyCode || e.which; 
			if (keyCode == 9) { 
				e.preventDefault(); 

				$('#tabParent_' + count).off('keydown', '#bundle_unit_'+ count , addRow);
				count ++;

				var newRow = '<tr>' +
				'<td><input id="name_' + count + '" class="textboxStyle2" type="text" maxlength="30"' +
					' name="name_' + count + '" />' +
				'</td>' +
				'<td><input class="textboxStyle5" type="number" maxlength="8" min ="0" max="99999999" ' +
					' name="barcode_' + count + '" />' +
				'</td>' +
				'<td><select class="selectStyle2" name="type_' + count + '" id="type_' + count + '">' +
				'</select>' +
				'</td>' +
				'<td><input class="textboxStyle4" type="text" maxlength="30"'+
					' name="category_' + count + '" />' +
				'</td>' +
				'<td><input class="textboxStyle4" type="text" maxlength="30"'+
					' name="manufacturer_' + count + '" />' +
				'</td>' +
				'<td><input class="textboxStyle3" type="number" maxlength="30" min="0"' +
					' name="cost_' + count + '" />' +
				'</td>' +
				'<td><input class="textboxStyle3" type="number" maxlength="30" min="0"' +
				' name="price_' + count + '" />' +
				'</td>' +
				'<td><input class="textboxStyle3" type="number" maxlength="30" min="0"' +
					' name="curr_stock_' + count + '" />' +
				'</td>' +
				'<td><input class="textboxStyle3" type="number" maxlength="30" min="0"' +
					' name="min_stock_' + count + '" />' +
				'</td>' +
				'<td>' +
					'<div id="tabParent_' + count + '">' +
						'<input class="textboxStyle3" type="number" maxlength="30" min="0"' +
							' name="bundle_unit_' + count + '" id="bundle_unit_' + count + '" />' +
					'</div>' +
				'</td>' +
			   '</tr>';
				
			   $('#classicTable tbody').append(newRow);
				$.each(myOptions, function(val, text) {
					$('#type_' + count).append($('<option></option>').val(val).html(text));					
				});
						
			   
			   $('#tabParent_' + count).on('keydown', '#bundle_unit_'+ count , addRow);
			   $('#name_' + count).focus();
			}
		}
		
		$('#tabParent_' + count).on('keydown', '#bundle_unit_'+ count , addRow);
	
	});
	</script>
</div>
<div style="margin-top: 10px">
	<input type="submit" value="submit" class="buttonStyle2">
</div>
<?php echo form_close();?>